home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-04 | 24.3 KB | 983 lines | [TEXT/MPS ] |
- /*
- * File: AERequest.cp
- *
- * Contains: xxx put contents here xxx
- *
- * Written by: Rick Violet
- *
- * Copyright: © 1992-1994 by Apple Computer, Inc., all rights reserved.
- *
- * Change History (most recent first):
- *
- * <4> 1/27/94 BD Relstring moved to TextUtils.h from Packages.h.
- * <3+> 1/27/94 BD Relstring moved to TextUtils.h from Packages.h.
- * <3> 1/27/94 BD Update for MPW 3.3, include TextUtils.h
- * <2+> 1/27/94 BD Update for MPW 3.3, include TextUtils.h
- * <1+> 1/13/94 CMW Update for new external tool protocol (AppleScriptable).
- * <1+> 5/18/93 RV Now accepts parameters of type 'true', 'fals', and 'BOOL' from
- * the Apple Events
- * <7+> 11/19/92 RV
- * 11/18/92 RV xxx put comment here xxx
- *
- * To Do:
- */
-
- #ifndef __AERequest__
- #include "AERequest.h"
- #endif
-
- #ifndef __RequestDispatcher__
- #include "RequestDispatcher.h"
- #endif
-
- #ifndef __ERRORS__
- #include <Errors.h>
- #endif
-
- #ifndef __TEXTUTILS__
- #include <TextUtils.h>
- #endif
-
- //—————————————————————————————————————————————————————————————————————————————————————
- // Global Variables
- //—————————————————————————————————————————————————————————————————————————————————————
- extern RequestDispatcher* gTheRequestDispatcher;
-
- //—————————————————————————————————————————————————————————————————————————————————————
- // AERequestHandler - handles 'v.u.' 'extc' apple event
- //—————————————————————————————————————————————————————————————————————————————————————
- pascal OSErr
- AERequestHandler( AppleEvent* pMessage, AppleEvent* pReply, long )
- {
- OSErr tErr;
- AERequest* tSrvReq;
-
- //———— Construct AERequest and put it in the request queue
- tSrvReq = new AERequest( pMessage, pReply );
- if( tSrvReq != nil )
- {
- tErr = tSrvReq->Initialize();
- if( tErr )
- {
- delete tSrvReq;
- }
- else
- {
- gTheRequestDispatcher->QueueRequest( tSrvReq );
- }
- }
-
- return( tErr );
- }
-
- //—————————————————————————————————————————————————————————————————————————————————————
- // AERequest::AERequest - constructor.
- //—————————————————————————————————————————————————————————————————————————————————————
- AERequest::AERequest( AppleEvent* pMessage, AppleEvent* pReply )
- {
- fMessagePtr = pMessage;
- fReplyPtr = pReply;
- fSuspended = false;
- fReturnID = 0;
- fHaveResetTimerMsg = false;
- }
-
- //—————————————————————————————————————————————————————————————————————————————————————
- // AERequest::~AERequest - destructor.
- //—————————————————————————————————————————————————————————————————————————————————————
- AERequest::~AERequest()
- {
-
- //———— Only if we successfully suspended the AppleEvent
- //———— are we responcible for disposing of the AppleEvent descriptors;
- //———— because the AppleEvent Manager will automatically
- //———— dispose of them when we return from the Handler.
- if( fSuspended )
- {
- AEDisposeDesc( fMessagePtr );
- AEDisposeDesc( fReplyPtr );
- }
-
- //———— if we created a TimeOut Reset AppleEvent, then dispose of it
- if( fHaveResetTimerMsg )
- {
- AEDisposeDesc( &fResetTimerMsg );
- }
- }
-
- //—————————————————————————————————————————————————————————————————————————————————————
- // AERequest::GetIdentifierOfRequesttoCancel - return the request
- // identifier of the request to cancel.
- // This method is for use with cancel requests only.
- //—————————————————————————————————————————————————————————————————————————————————————
- long
- AERequest::GetIdentifierOfRequesttoCancel()
- {
- ScriptValue* tVal;
- ValueKind tVKind = kVUAnyKind;
- long tResult = 0;
-
- GetNthParam( 1, tVal, tVKind );
- if( tVal )
- {
- switch( tVKind )
- {
- case kVULongNumberKind:
- {
- tResult = ((VULongNumber*)tVal)->GetNumber();
- }
- break;
-
- case kVUStringKind:
- {
- stringtonum( ((VUString*)tVal)->GetText(), &tResult );
- }
- break;
- }
- }
-
- return tResult;
- }
-
- //—————————————————————————————————————————————————————————————————————————————————————
- // AERequest::InstallAppleEventHandler - Install an AppleEvent Handler
- // into the AE dispatch table for receiving
- // Apple Events from V.U.
- //—————————————————————————————————————————————————————————————————————————————————————
- OSErr
- AERequest::InstallAppleEventHandler()
- {
- return AEInstallEventHandler( kVUAETool,
- kVUAESendService,
- (EventHandlerProcPtr)AERequestHandler,
- 0, false);
-
- }
-
- //—————————————————————————————————————————————————————————————————————————————————————
- // AERequest::SetErrorCode - set the Error code for this request
- //—————————————————————————————————————————————————————————————————————————————————————
- void
- AERequest::SetErrorCode( OSErr tErr )
- {
- if( fReplyPtr != nil )
- {
- AEPutAttributePtr( fReplyPtr,
- keyErrorNumber,
- typeShortInteger,
- (Ptr)&tErr,
- sizeof( OSErr ) );
- }
-
- Request::SetErrorCode( tErr );
- }
-
- //—————————————————————————————————————————————————————————————————————————————————————
- // AERequest::SetErrorMessage - set the Error message for this request
- //—————————————————————————————————————————————————————————————————————————————————————
- void
- AERequest::SetErrorMessage( char* tErrText )
- {
- if( fReplyPtr != nil )
- {
- AEPutAttributePtr( fReplyPtr,
- keyErrorString,
- typeChar,
- (Ptr)tErrText,
- strlen( tErrText ) );
- }
-
- Request::SetErrorMessage( tErrText );
- }
-
- //—————————————————————————————————————————————————————————————————————————————————————
- // AERequest::Initialize - initialize the Request
- // Transfers info in AppleEvents to the
- // Request object
- //—————————————————————————————————————————————————————————————————————————————————————
- OSErr
- AERequest::Initialize()
- {
- OSErr tErr = noErr;
-
- //———— Suspend processing of the AppleEvent by the AE Manager
- //———— This prevents the reply AppleEvent from being sent back
- //———— when this routine returns ( actually it's when the AE Handler returns ).
- tErr = AESuspendTheCurrentEvent( fMessagePtr );
- if( tErr != noErr )
- {
- fSuspended = false;
- return tErr;
- }
- else
- {
- fSuspended = true;
- }
-
- //———— Duplicate the AppeEvent Record, and reset the pointers
- fMessage = *fMessagePtr;
- fMessagePtr = &fMessage;
-
- fReply = *fReplyPtr;
- fReplyPtr = &fReply;
-
-
- //———— Get the return ID of the AppleEvent
- tErr = SetupReturnID();
- if( tErr != noErr )
- {
- SetErrorCode( tErr );
- SetErrorMessage( "Failed to extract return id from AppleEvent." );
- return tErr;
- }
-
- //———— Get the Service Indentifier from the AppleEvent
- //———— This string identifies which service is requested
- tErr = SetupSeviceIdentifier();
- if( tErr != noErr )
- {
- SetErrorCode( tErr );
- SetErrorMessage( "Failed to extract service identifier." );
- return tErr;
- }
-
- //———— Get the service parameters from the AppleEvent
- //———— and install them into this Request.
- tErr = SetupParameterList();
- if( tErr != noErr )
- {
- SetErrorCode( tErr );
- SetErrorMessage( "Failed to extract parameters." );
- return tErr;
- }
-
- //———— Get the service parameters from the AppleEvent
- //———— and install them into this Request.
- tErr = SetupRequestIdentifier();
- if( tErr != noErr )
- {
- SetErrorCode( tErr );
- SetErrorMessage( "Failed to extract return ID." );
- return tErr;
- }
-
- //———— Call Parent class's Initialize
- tErr = Request::Initialize();
- if( tErr )
- {
- return tErr;
- }
-
- return noErr;
- }
-
- //—————————————————————————————————————————————————————————————————————————————————————
- // AERequest::SetupReturnID - Get the AppleEvent's return ID
- //—————————————————————————————————————————————————————————————————————————————————————
- OSErr
- AERequest::SetupReturnID()
- {
- OSErr tErr;
- long tResult;
- DescType tActualType;
- Size tActualSize;
-
- tErr = AEGetAttributePtr( fMessagePtr,
- keyReturnIDAttr,
- typeLongInteger,
- &tActualType,
- (Ptr)&tResult,
- sizeof( tResult ),
- &tActualSize );
- if( tErr == noErr )
- {
- fReturnID = tResult;
- }
- else
- {
- fReturnID = 0;
- }
- return tErr;
- }
-
- //—————————————————————————————————————————————————————————————————————————————————————
- // AERequest::SetupSeviceIdentifier - Get the AppleEvent's direct parameter
- // It contains the text which identifies
- // which service is requested
- //—————————————————————————————————————————————————————————————————————————————————————
- OSErr
- AERequest::SetupSeviceIdentifier()
- {
- OSErr tErr;
- char tText[256];
- DescType tActualType;
- Size tActualSize;
-
- tErr = AEGetParamPtr( fMessagePtr,
- kVUAESrvcName,
- typeChar,
- &tActualType,
- (Ptr)tText,
- 255,
- &tActualSize );
- if( tErr == noErr )
- {
- tText[tActualSize] = '\0'; //———— Terminate C string with null character
- SetWhichService( tText );
- }
- else
- {
- SetWhichService( nil );
- }
- return tErr;
- }
-
- //—————————————————————————————————————————————————————————————————————————————————————
- // AERequest::SetupParameterList - Get the AppleEvent's 'extp' parameter
- // It contains the list of parameters for the Service
- //—————————————————————————————————————————————————————————————————————————————————————
- OSErr
- AERequest::SetupParameterList()
- {
- OSErr tErr;
- AEDescList tParamDesc;
- VUList* tParamValue;
-
- tErr = AEGetParamDesc( fMessagePtr,
- kVUAESrvcParameters,
- typeAEList,
- &tParamDesc );
- if( tErr != noErr )
- {
- //———— Some services may have no parameters,
- //———— so allow errAEDescNotFound error
- if( tErr == errAEDescNotFound )
- {
- return noErr;
- }
- else
- {
- return tErr;
- }
- }
- else
- {
- tErr = MakeVUListFromDescList( &tParamDesc, &tParamValue );
- if( tParamValue != nil )
- {
- SetParameterList( tParamValue );
- }
- AEDisposeDesc( &tParamDesc );
- }
- return tErr;
- }
-
- //—————————————————————————————————————————————————————————————————————————————————————
- // AERequest::SetupRequestIdentifier - Get the AppleEvent's return ID
- //—————————————————————————————————————————————————————————————————————————————————————
- OSErr
- AERequest::SetupRequestIdentifier()
- {
- OSErr tErr;
- long tReturnID;
- DescType tActualType;
- Size tActualSize;
-
- tErr = AEGetAttributePtr( fMessagePtr,
- keyReturnIDAttr,
- typeLongInteger,
- &tActualType,
- (Ptr)&tReturnID,
- sizeof( long ),
- &tActualSize );
- if( tErr == noErr )
- {
- //———— Set the Request Identifier
- SetRequestIdentifier( tReturnID );
- }
- else
- {
- //———— Set the Request Identifier to zero
- SetRequestIdentifier( 0 );
- }
- return tErr;
- }
-
- //—————————————————————————————————————————————————————————————————————————————————————
- // AERequest::MakeVUListFromDescList - Convert the AEDescList
- // to a VUList object.
- //—————————————————————————————————————————————————————————————————————————————————————
- OSErr
- AERequest::MakeVUListFromDescList( AEDescList* pDescList, VUList** pValue )
- {
- OSErr tErr;
- long tParamCount;
- long i;
- AEKeyword tActualKey;
- DescType tActualType;
- Size tActualSize;
- short tShort;
- long tLong;
- Boolean tBoolean;
- char* tText;
- AEDescList tDescList;
- VUList* tReturnVUList;
- VUList* tVUList;
-
-
- //———— Construct the VUList object to eventually return
- tReturnVUList = new VUList();
- if( tReturnVUList == nil )
- {
- pValue = nil;
- return memFullErr;
- }
-
- //———— Get the number of Descriptors in the list
- tErr = AECountItems( pDescList, &tParamCount );
- if( tErr )
- {
- pValue = nil;
- return tErr;
- }
-
- //———— For each Descriptor in the list
- for( i = 1; i <= tParamCount; i++ )
- {
- //———— Determine the type of the ith Descriptor
- tErr = AESizeOfNthItem( pDescList, i, &tActualType, &tActualSize );
- if( tErr )
- {
- break;
- }
-
- //———— Depending on the type,
- //———— Extract the data and put it into ScriptValue
- switch( tActualType )
- {
- //————————————————————————————————————————————————————
- //———— typeBoolean, typeFalse, typeTrue
- case typeBoolean:
- case typeTrue:
- case typeFalse:
- {
- //———— typeBoolean
- if( tActualType == typeBoolean )
- {
- tErr = AEGetNthPtr( pDescList,
- i,
- tActualType,
- &tActualKey,
- &tActualType,
- (Ptr)&tBoolean,
- sizeof(Boolean),
- &tActualSize );
- if( tErr == noErr )
- {
- tReturnVUList->PutNthItem( tBoolean ); //———— defaults to appending
- }
- }
- else
- {
- //———— typeFalse & typeFalse
- tReturnVUList->PutNthItem( (Boolean)(tActualType == typeTrue) ); //———— defaults to appending
- }
- }
- break;
-
- //————————————————————————————————————————————————————
- //———— typeShortInteger
- case typeShortInteger:
- {
- tErr = AEGetNthPtr( pDescList,
- i,
- typeShortInteger,
- &tActualKey,
- &tActualType,
- (Ptr)&tShort,
- sizeof(short),
- &tActualSize );
- if( tErr == noErr )
- {
- tReturnVUList->PutNthItem( tShort ); //———— defaults to appending
- }
- }
- break;
-
- //————————————————————————————————————————————————————
- //———— typeLongInteger
- case typeLongInteger:
- {
- tErr = AEGetNthPtr( pDescList,
- i,
- typeLongInteger,
- &tActualKey,
- &tActualType,
- (Ptr)&tLong,
- sizeof(long),
- &tActualSize );
- if( tErr == noErr )
- {
- tReturnVUList->PutNthItem( tLong ); //———— defaults to appending
- }
- }
- break;
-
- //————————————————————————————————————————————————————
- //———— typeChar
- case typeChar:
- {
- tText = new char[ tActualSize + 1 ];
- if( tText )
- {
- tErr = AEGetNthPtr( pDescList,
- i,
- typeChar,
- &tActualKey,
- &tActualType,
- (Ptr)tText,
- tActualSize + 1,
- &tActualSize );
- if( tErr == noErr )
- {
- tText[tActualSize] = '\0';
- tReturnVUList->PutNthItem( tText ); //———— defaults to appending
- }
- delete tText;
- }
- }
- break;
-
- //————————————————————————————————————————————————————
- //———— typeAEList
- //———— We have to make a recursive call to this same method
- //———— in order to accomplish translation of an AEDescList
- case typeAEList:
- {
- //———— Extract the AEDescList
- tErr = AEGetNthDesc( pDescList,
- i,
- typeAEList,
- &tActualKey,
- &tDescList );
- if( tErr == noErr )
- {
- //———— Now convert the DescList into a VUList
- tErr = MakeVUListFromDescList( &tDescList, &tVUList );
- if( tErr == noErr )
- {
- if( tVUList != nil )
- {
- tReturnVUList->PutNthItem( tVUList ); //———— defaults to appending
- }
- }
- AEDisposeDesc( &tDescList );
- }
- }
- break;
-
- //————————————————————————————————————————————————————
- //———— default case, unknown data type in AEDesc
- //———— use VUNull to represent an 'undefined'
- //———— It also forms a place holder so list
- //———— elements retail their order, and errors are
- //———— isolated with less grief
- default:
- {
- tReturnVUList->PutNthItem( new VUNull() );
- }
- break;
-
- }
-
- //———— Break out of FOR loop if an error was encountered
- if( tErr != noErr )
- {
- break;
- }
- }
- *pValue = tReturnVUList;
- return tErr;
- }
-
- //—————————————————————————————————————————————————————————————————————————————————————
- // AERequest::ResetTimeOutCounter - inform V.U. to not let this AppleEvent
- // time out for the indicated number of seconds
- //—————————————————————————————————————————————————————————————————————————————————————
- void
- AERequest::ResetTimeOutCounter( unsigned long pNewTimeOutInterval )
- {
- const unsigned long kResetSendThreshold = 600;
-
- if( !HasBeenCanceled() )
- {
- if( fSendResetTicks - TickCount() < kResetSendThreshold )
- {
- //———— Send message to V.U. to reset the time out counter
- SendTimeOutResetMessage( pNewTimeOutInterval );
-
- //———— Call Parent class method
- Request::ResetTimeOutCounter( pNewTimeOutInterval );
- }
- }
- }
-
- //—————————————————————————————————————————————————————————————————————————————————————
- // AERequest::SendTimeOutResetMessage - Send an AppleEvent to V.U. to
- // reset the Time Out counter for this AppleEvent
- //—————————————————————————————————————————————————————————————————————————————————————
- OSErr
- AERequest::SendTimeOutResetMessage( unsigned long pNewTimeOutInterval )
- {
- OSErr tErr;
- AEAddressDesc tAddressDesc;
- AppleEvent tDummyReply;
-
- //———— If we have not already built an event for reseting the timer, do so now
- if( !fHaveResetTimerMsg )
- {
- //———— Get the Target Address Descriptor from the existing default reply AppleEvent
- tErr = AEGetAttributeDesc( fReplyPtr,
- keyAddressAttr,
- typeWildCard,
- &tAddressDesc );
- if( tErr )
- {
- //———— not much further we can do, except return the error code
- return tErr;
- }
-
-
- //———— Construct the AppleEvent for sending to V.U.
- tErr = AECreateAppleEvent( kVUAETool,
- kVUAEWaitLonger,
- &tAddressDesc,
- kAutoGenerateReturnID,
- kAnyTransactionID,
- &fResetTimerMsg );
- //———— We no longer need the Address descriptor
- AEDisposeDesc( &tAddressDesc );
- if( tErr )
- {
- //———— not much further we can do, except return the error code
- return tErr;
- }
-
- //———— Put the same return ID as the original AppleEvent from V.U.
- //———— V.U. uses the return ID to determine which AppleEvent needs its timer reset
- tErr = AEPutAttributePtr( &fResetTimerMsg,
- keyReturnIDAttr,
- typeLongInteger,
- (Ptr)&fReturnID,
- sizeof( long ) );
-
- //———— We now have an AppleEvent that we can send, and we need to dispose of later
- fHaveResetTimerMsg = true;
- }
-
- //———— Put the amount of time required to complete the current service request
- //———— into the AppleEvent
- tErr = AEPutParamPtr( &fResetTimerMsg,
- kVUAEWaitAmount,
- typeMagnitude,
- (Ptr)&pNewTimeOutInterval,
- sizeof( pNewTimeOutInterval ) );
- if( tErr )
- {
- //———— not much further we can do, except return the error code
- return tErr;
- }
-
-
- tErr = AESend( &fResetTimerMsg,
- &tDummyReply,
- kAENoReply + kAENeverInteract,
- kAEHighPriority,
- kAEDefaultTimeout,
- nil,
- nil );
- if( tErr )
- {
- //———— not much further we can do, except return the error code
- return tErr;
- }
-
- return noErr;
- }
-
- //—————————————————————————————————————————————————————————————————————————————————————
- // AERequest::SendResult - send the result back to VU
- //—————————————————————————————————————————————————————————————————————————————————————
- void
- AERequest::SendResult()
- {
- OSErr tErr;
-
- //———— If a return value exists, install it in the reply event
- if( fReturnValue != nil )
- {
- tErr = PutReturnValueIntoReplyEvent();
- }
-
- //———— Resume the processing of this AppleEvent pair
- //———— This causes the reply event to be sent back to V.U.
- tErr = AEResumeTheCurrentEvent( fMessagePtr,
- fReplyPtr,
- (EventHandlerProcPtr)kAENoDispatch,
- 0 );
-
- if( tErr == noErr )
- {
- fSuspended = false;
- }
- }
-
- //—————————————————————————————————————————————————————————————————————————————————————
- // AERequest::PutReturnValueIntoReplyEvent - Convert the ScriptValue
- // to an AE Descriptor.
- //—————————————————————————————————————————————————————————————————————————————————————
- OSErr
- AERequest::PutReturnValueIntoReplyEvent()
- {
- OSErr tErr;
- Boolean tBoolean;
- short tShort;
- long tLong;
- char* tText;
- unsigned short tTextSize;
- AEDescList tDescList;
-
- //———— Put the value into the reply event according to its kind
- switch( fReturnValue->GetValueKind() )
- {
- case kVUBooleanKind:
- {
- tBoolean = ((VUBoolean*)fReturnValue)->GetBoolean();
- if( tBoolean )
- {
- tErr = AEPutParamPtr( fReplyPtr,
- kVUAESrvcResults,
- typeTrue,
- (Ptr)&tBoolean,
- sizeof(Boolean) );
- }
- else
- {
- tErr = AEPutParamPtr( fReplyPtr,
- kVUAESrvcResults,
- typeFalse,
- (Ptr)&tBoolean,
- sizeof(Boolean) );
- }
- if( tErr )
- {
- SetErrorCode( tErr );
- SetErrorMessage( "Failed to install return value into the reply." );
- }
- }
- break;
-
- case kVUNumberKind:
- {
- tShort = ((VUNumber*)fReturnValue)->GetNumber();
- tErr = AEPutParamPtr( fReplyPtr,
- kVUAESrvcResults,
- typeShortInteger,
- (Ptr)&tShort,
- sizeof(short) );
- if( tErr )
- {
- SetErrorCode( tErr );
- SetErrorMessage( "Failed to install return value into the reply." );
- }
- }
- break;
-
- case kVULongNumberKind:
- {
- tLong = ((VULongNumber*)fReturnValue)->GetNumber();
- tErr = AEPutParamPtr( fReplyPtr,
- kVUAESrvcResults,
- typeLongInteger,
- (Ptr)&tLong,
- sizeof(long) );
- if( tErr )
- {
- SetErrorCode( tErr );
- SetErrorMessage( "Failed to install return value into the reply." );
- }
- }
- break;
-
- case kVUStringKind:
- {
- tText = ((VUString*)fReturnValue)->GetText();
- if( tText != nil )
- {
- if( (tTextSize = strlen( tText )) > 0)
- {
- tErr = AEPutParamPtr( fReplyPtr,
- kVUAESrvcResults,
- typeChar,
- (Ptr)tText,
- tTextSize );
- if( tErr )
- {
- SetErrorCode( tErr );
- SetErrorMessage( "Failed to install return value into the reply." );
- }
- }
- }
- }
- break;
-
- case kVUListKind:
- {
- tErr = MakeDescListFromVUList( (VUList*)fReturnValue, &tDescList );
- if( tErr == noErr )
- {
- tErr = AEPutParamDesc( fReplyPtr,
- kVUAESrvcResults,
- &tDescList );
- AEDisposeDesc( &tDescList );
- }
- }
- break;
-
- default:
- {
-
- }
- break;
- }
-
-
- return tErr;
- }
-
- //—————————————————————————————————————————————————————————————————————————————————————
- // AERequest::MakeDescListFromVUList - Convert the VUList
- // to a pDescList object.
- //—————————————————————————————————————————————————————————————————————————————————————
- OSErr
- AERequest::MakeDescListFromVUList( VUList* pValue, AEDescList* pDescList )
- {
- OSErr tErr;
- short tItemCount;
- short i;
- ScriptValue* tVal;
- Boolean tBoolean;
- short tShort;
- long tLong;
- char* tText;
- AEDescList tDescList;
- ValueKind tValueKind;
-
- //———— Create the AEDescList to fill with the values in the VUList
- tErr = AECreateList( nil, 0, false, pDescList );
- if( tErr )
- {
- return tErr;
- }
- //———— Get the number of items in the VUList
- tItemCount = pValue->GetCount();
-
- //———— Put each item of the VUList, into the AEDescList
- for( i = 1; i <= tItemCount; i++ )
- {
- //———— Get the ith ScriptValue object from the VUList
- tValueKind = kVUAnyKind;
- tErr = pValue->GetNthItem( i, tVal, tValueKind );
- if( tVal )
- {
- //———— if we got one, process it according to its kind
- switch( tValueKind )
- {
-
- //———— VUBoolean object
- case kVUBooleanKind:
- {
- tBoolean = ((VUBoolean*)tVal)->GetBoolean();
- tErr = AEPutPtr( pDescList,
- i,
- typeBoolean,
- (Ptr)&tBoolean,
- sizeof(Boolean) );
- }
- break;
-
- //———— VUNumber object
- case kVUNumberKind:
- {
- tShort = ((VUNumber*)tVal)->GetNumber();
- tErr = AEPutPtr( pDescList,
- i,
- typeShortInteger,
- (Ptr)&tShort,
- sizeof(short) );
- }
- break;
-
- //———— VULongNumber object
- case kVULongNumberKind:
- {
- tLong = ((VULongNumber*)tVal)->GetNumber();
- tErr = AEPutPtr( pDescList,
- i,
- typeLongInteger,
- (Ptr)&tLong,
- sizeof(long) );
- }
- break;
-
- //———— VUString object
- case kVUStringKind:
- {
- tText = ((VUString*)tVal)->GetText();
- if( tText )
- {
- tErr = AEPutPtr( pDescList,
- i,
- typeChar,
- (Ptr)tText,
- strlen(tText) );
- }
- }
- break;
-
- //———— VUList object
- case kVUListKind:
- {
- tErr = MakeDescListFromVUList( (VUList*)tVal, &tDescList );
- if( tErr == noErr )
- {
- tErr = AEPutDesc( pDescList,
- i,
- &tDescList );
- AEDisposeDesc( &tDescList );
- }
- }
- break;
-
- default:
- {
- }
- break;
- }
- //———— Break out of for loop, if there was an error
- if( tErr )
- {
- break;
- }
- }
- }
-
- //———— if there was an error, dispose of the AEDescList created earlier
- if( tErr )
- {
- AEDisposeDesc( &tDescList );
- }
- return tErr;
- }
-
-